package ve.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idPerson;

    @OneToMany private Collection<ScoreCard> scoreCards;

    @OneToMany private Collection<Note> notes;

    @OneToMany private Collection<PointerComparator> pointerComparators;

    @OneToMany private Collection<Panel> panels;

    @ManyToMany(targetEntity=ScoreDomain.class) @JoinTable(name="PersonScoreDomain", joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idScoreDomain")) private Collection<ScoreDomain> scoreDomains;
    
    @ManyToMany(targetEntity=Profile.class) @JoinTable(name="PersonProfile", joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idProfile")) private Collection<Profile> profiles;

    @ManyToMany(targetEntity=Cluster.class) @JoinTable(name="PersonCluster", joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idCluster")) private Collection<Cluster> clusters;

    @ManyToMany(targetEntity=ScoreCard.class) @JoinTable(name="Alert", joinColumns=@JoinColumn(name="idPerson"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard")) private Collection<ScoreCard> suscriptions;

    @Column(columnDefinition="text") private String username;

    @Column(columnDefinition="text") private String password;
    
    @Column(columnDefinition="text") private String email;
    
    @Column(columnDefinition="text") private String name;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Collection<ScoreCard> getSuscriptions() {
        return suscriptions;
    }

    public void setSuscriptions(Collection<ScoreCard> suscriptions) {
        this.suscriptions = suscriptions;
    }

    public Collection<Panel> getPanels() {
        return panels;
    }

    public void setPanels(Collection<Panel> panels) {
        this.panels = panels;
    }

    public Collection<PointerComparator> getPointerComparators() {
        return pointerComparators;
    }

    public void setPointerComparators(Collection<PointerComparator> pointerComparators) {
        this.pointerComparators = pointerComparators;
    }

    public Collection<Cluster> getClusters() {
        return clusters;
    }

    public void setClusters(Collection<Cluster> clusters) {
        this.clusters = clusters;
    }

    public Collection<Profile> getProfiles() {
        return profiles;
    }

    public void setProfiles(Collection<Profile> profiles) {
        this.profiles = profiles;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Collection<Note> getNotes() {
        return notes;
    }

    public void setNotes(Collection<Note> notes) {
        this.notes = notes;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Collection<ScoreDomain> getScoreDomains() {
        return scoreDomains;
    }

    public void setScoreDomains(Collection<ScoreDomain> scoreDomains) {
        this.scoreDomains = scoreDomains;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Long getIdPerson() {
        return idPerson;
    }

    public void setIdPerson(Long idPerson) {
        this.idPerson = idPerson;
    }

    public Collection<ScoreCard> getScoreCards() {
        return scoreCards;
    }

    public void setScoreCards(Collection<ScoreCard> scoreCards) {
        this.scoreCards = scoreCards;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPerson != null ? idPerson.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.idPerson == null && other.idPerson != null) || (this.idPerson != null && !this.idPerson.equals(other.idPerson))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.Person[id=" + idPerson + "]";
    }

}//ends of class
